package com.shujia.wyh.mr.youhua;

import com.shujia.wyh.mr.tuijian.MyPersonMapper;
import com.shujia.wyh.mr.tuijian.MyPersonReducer;
import com.shujia.wyh.mr.tuijian.PersonDemo;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.ReduceTask;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

/*
    求出每一年的2月份的最高温度
 */
public class WeatherDemo {
    public static void main(String[] args) throws Exception {
        //获取集群的配置文件
        Configuration conf = new Configuration();

        //创建Job作业
        Job job = Job.getInstance(conf);

        job.setJarByClass(WeatherDemo.class);
        job.setJobName("Hadoop优化之Combiner");

        job.setMapperClass(MyWeatherMapper.class);
        job.setMapOutputKeyClass(Text.class);
        job.setMapOutputValueClass(LongWritable.class);

//        job.setReducerClass(MyWeatherReducer.class);
//        job.setOutputKeyClass(Text.class);
//        job.setOutputValueClass(LongWritable.class);
        job.setCombinerClass(MyWeatherReducer.class);

        FileInputFormat.addInputPath(job,new Path(args[0]));
        FileOutputFormat.setOutputPath(job,new Path(args[1]));

        job.waitForCompletion(true);

    }
}
